<template>
  <div class="center-cmp">
    <div class="cc-header">
      <dv-decoration-1 style="width:200px;height:50px;" />
      <div style="display:none;">瀑拉谷葡萄种植基地</div>
      <dv-decoration-1 style="width:200px;height:50px;" />
    </div>

    <div class="cc-details" style="display:none;">
      <!-- <div>种植面积</div> -->
      <div
        v-for="(item,index) in sumData"
        :key="index"
        class="card"
      >
        {{ item }}
      </div>
      <div>亩</div>
    </div>

    <div class="cc-main-container">
      <div class="ccmc-left" style="display:none">
        <div class="station-info">
          {{ fieldsData[0].name }}
        </div>
        <div class="station-info">
          面积
          <span>{{ fieldsData[0].area }}亩</span>
        </div>
        <div class="station-info">
          种类
          <span>{{ fieldsData[0].crop_count }}</span>
        </div>
        <div class="station-info">
          数量
          <span>{{ fieldsData[0].crop_nums }}棵</span>
        </div>
      </div>

      <!-- <dv-active-ring-chart class="ccmc-middle" :config="config" /> -->
      <dv-flyline-chart
        class="ccmc-middle"
        :config="config"
        style="width:60%;height:100%;margin:0 auto;"
      />

      <div class="ccmc-right" style="display:none">
        <div class="station-info">
          {{ fieldsData[1].name }}
        </div>
        <div class="station-info">
          <span>{{ fieldsData[1].area }}亩</span>面积
        </div>
        <div class="station-info">
          <span>{{ fieldsData[1].crop_count }}</span>种类
        </div>
        <div class="station-info">
          <span>{{ fieldsData[1].crop_nums }}棵</span>数量
        </div>
      </div>

      <!-- <LabelTag :config="labelConfig" /> -->
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  name: 'CenterCmp',
  props: {
    fieldsData: {
      type: Array,
      default() {
        return [{}, {}]
      }
    }
  },
  data() {
    return {
      sumData: [],
      config: {
        centerPoint: [],
        points: [
          [0.52, 0.23],
          [0.43, 0.29],
          [0.59, 0.35],
          [0.53, 0.47],
          [0.45, 0.54],
          [0.36, 0.38],
          [0.62, 0.55],
          [0.56, 0.56],
          [0.37, 0.66],
          [0.55, 0.81],
          [0.55, 0.67],
          [0.37, 0.29],
          [0.20, 0.36],
          [0.76, 0.41],
          [0.59, 0.18],
          [0.68, 0.17],
          [0.59, 0.10]
        ],
        bgImgUrl: '',
        centerPointImg: {
          url: 'https://www.zesi.com.cn/storage/datav/mapCenterPoint.png'
        },
        pointsImg: {
          url: 'https://www.zesi.com.cn/storage/datav/mapPoint.png'
        }
      }
    }
  },
  computed: {
    ...mapGetters(['project'])
  },
  watch: {
    project: {
      handler(newVal) {
        if (newVal) {
          this.config.centerPoint = newVal.datav_center.split(',').map(val => +val)
          this.config.bgImgUrl = newVal.datav_bg
        }
      },
      deep: true,
      immediate: true
    },
    fieldsData: {
      handler(newVal, oldVal) {
        if (newVal) {
          const res = newVal.reduce((sum, current) => {
            return sum + Number(current.area)
          }, 0)
          this.sumData = res.toString().split('')
        }
      },
      deep: true,
      immediate: true
    }
  }
}
</script>

<style lang="scss">
.center-cmp {
  width: 100%;
  height: 100%;
  margin: 0px;
  padding: 0px;
  display: flex;
  flex-direction: column;

  .cc-header {
    height: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 24px;
  }

  .cc-details {
    height: 120px;
    display: flex;
    justify-content: center;
    font-size: 32px;
    align-items: center;

    .card {
      background-color: rgba(4, 49, 128, 0.6);
      color: #08e5ff;
      height: 70px;
      width: 70px;
      font-size: 45px;
      font-weight: bold;
      line-height: 70px;
      text-align: center;
      margin: 10px;
    }
  }

  .cc-main-container {
    position: relative;
    flex: 1;
    display: flex;

    .ccmc-middle {
      width: 40%;
      height: 60%;

      .active-ring-name {
        font-size: 20px !important;
      }
    }

    .ccmc-left,
    .ccmc-right {
      display:none;
      width: 20%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      font-size: 16px;

      span {
        font-size: 21px;
        font-weight: bold;
      }

      .station-info {
        height: 60px;
        display: flex;
        align-items: center;
      }
    }

    .ccmc-left {
      // align-items: flex-end;
      padding-left: 32px;
      span {
        margin-left: 20px;
      }
    }

    .ccmc-right {
      align-items: flex-end;
      padding-right: 32px;
      span {
        margin-right: 20px;
      }
    }
  }

  .label-tag {
    position: absolute;
    width: 500px;
    height: 30px;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
  }
}
</style>
